package cate.common.table.farm.adventure.row;

import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import cate.common.table.d.GDPosition;
import cp.solution.util.str.Str;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

public class AdventureCharpterRow extends ERow {
    @NoteField("关卡")
    public String section;

    @NoteField("关卡资源")
    public String sectionResource;

    @NoteField("关卡奖励")
    public String rewardStr;

    @NoteField("额外奖励")
    public String extraReward;

    @NoteField("特殊奖励")
    public String specialRewardStr;

    @NoteField("玩家等级")
    public int levelReq;

    @NoteField("推荐战力")
    public long recPower;

    @NoteField("怪物方实例")
    public String dynInsCode;

    @NoteField("怪物方二队实例")
    public String dynInsCode2;

    @NoteField("怪物方三队实例")
    public String dynInsCode3;

    @NoteField("挂机奖励")
    public String hangReward;

    @NoteField("掉落ID")
    public String dropIdHangCode;

    @NoteField("食灵经验特权")
    public String privilegeReward;

    @NoteField("掉落2")
    public String drop2;

    @NoteField("每小时进阶石")
    public int everyHourStone;

    @Override
    public void parse(XSSFRowWrap xrw) {
        super.parse(xrw);
        this.id = xrw.getInteger("ID");
        this.section = xrw.getString("关卡");
        this.sectionResource = xrw.getString("关卡资源");
        this.rewardStr = xrw.getString("关卡奖励");
        this.extraReward = xrw.getString("额外奖励");
        this.levelReq = xrw.getInteger("玩家等级", 0);
        this.recPower = xrw.getLong("推荐战力", 0L);
        this.dynInsCode = xrw.getString("怪物方实例");
        this.dynInsCode2 = xrw.getString("怪物方二队实例");
        this.dynInsCode3 = xrw.getString("怪物方三队实例");

        this.hangReward = xrw.getString("挂机奖励");
        this.dropIdHangCode = xrw.getString("掉落ID");
        this.privilegeReward = xrw.getString("食灵经验特权");
        this.drop2 = xrw.getString("掉落2");
        this.specialRewardStr = xrw.getString("特殊奖励");
        this.everyHourStone = xrw.getInteger("每小时进阶石",0);
    }

    @NoteField("掉落ID")
    public List<Integer> dropIdList;

    @NoteField("掉落2")
    public List<String> drop2StrList;

    @Override
    public void decode() {
        if (!StringUtils.isBlank(rewardStr)) {
            dropIdList = Str.strArr2intList(rewardStr.split("#"));
        }
        if (!StringUtils.isBlank(drop2)) {
            drop2StrList = Str.strArr2strList(drop2.split("#"));
        }

    }

    public String getInsCode(byte posNum) {
        switch (posNum) {
            case GDPosition.POS_ONE:
                return dynInsCode;
            case GDPosition.POS_TWO:
                return dynInsCode2;
            case GDPosition.POS_THREE:
                return dynInsCode3;
        }
        return null;
    }

    public int getPosNum() {
        int num = 0;
        if (StringUtils.isNotBlank(dynInsCode)) {
            num++;
        }
        if (StringUtils.isNotBlank(dynInsCode2)) {
            num++;
        }
        if (StringUtils.isNotBlank(dynInsCode3)) {
            num++;
        }
        return num;
    }

}
